package com.itheima.demo;


import com.itheima.utils.JedisUtils;
import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.List;

public class demo1Redis {
    @Test
    public void test1(){
        //【第一步】创建Jedis对象
        Jedis jedis = new Jedis("192.168.223.128",6379);
        jedis.auth("123456");

        jedis.set("user","snake");
        System.out.println("user");
        jedis.close();

    }
    @Test
    public void testList(){
        //1 从工具类中获取连接
        Jedis jedis = JedisUtils.getJedis();
        //2 执行操作
        jedis.lpush("hobbies","sing","dance","rap","basketball");

        List<String> list = jedis.lrange("hobbies", 0, -1);
        System.out.println(list);
        //3 释放资源
        JedisUtils.close(jedis);
    }
}
